<?php 
include_once 'inc/config.php';
include_once 'inc/mysql.class.php';
include_once 'smrty.php';
$mysql = new mysql();
$mysql->open($dbconfig);
//查询办事处
if ($_GET['do']=="s") {
	if ($_GET['order_id']!="") {
		$banshichulist = $mysql->select("*", "banshichu","`order_id`=$_GET[order_id]");
		include_once 'fun/myfunction.php';
		for ($i = 0; $i < count($banshichulist); $i++) {
			$banshichulist[$i]['listdeta']=json_banshichu($banshichulist[$i]['listdeta'], "");
		}
		$smarty->assign('order_id',$_GET[order_id]);
		$smarty->assign('banshichulist',$banshichulist);
		$smarty->display('banshichu_list.html');		
	}
}elseif ($_GET['do']=="edit"){
	if ($_POST[listdeta]) {
		$data=array();
		if ($_POST[banshi])$data[banshi]=$_POST[banshi];
		if ($_POST[listdeta])$data[listdeta]=$_POST[listdeta];
		if ($mysql->update($data, "banshichu","`id`=$_POST[id]")) {
		echo "<script language='javascript'>location='banshichu.php?do=s&order_id=$_POST[order_id]';</script>";}else {echo "更新失败";}
	}else {
		if ($_GET[id]!=""){
			$banshichu = $mysql->get_one("*", "banshichu","`id`=$_GET[id]");
			include_once 'fun/myfunction.php';
			$banshichu['listdeta']=json_banshichu($banshichu['listdeta'],"edittable");
			$smarty->assign('banshichu',$banshichu);
			$smarty->display('banshichu_edit.html');				
		}
	}	
}elseif ($_GET['do']=="add"){
	if ($_POST[listdeta]) {
		$data=array();
		if ($_POST[banshi])$data[banshi]=$_POST[banshi];
		if ($_POST[listdeta])$data[listdeta]=$_POST[listdeta];
		if ($_POST[order_id])$data[order_id]=$_POST[order_id];
		$data[newdate]=date('y-m-d');
		if ($mysql->insert($data, "banshichu")) {
		echo "<script language='javascript'>location='banshichu.php?do=s&order_id=$_POST[order_id]';</script>";}else{echo "添加失败";}
	}else {
			$smarty->assign('order_id',$_GET[order_id]);
			$smarty->display('banshichu_add.html');			
	};
}elseif ($_GET['do']=="del"){
	;
}
?>
